package subject_set.offer100;

import java.util.ArrayList;
import java.util.List;

/**
 * @author haomin
 * @date 2022/10/25 16:02
 **/
public class Offer57_Ⅱ {
    class Solution {
        public int[][] findContinuousSequence(int target) {
            int l = 1, r = 2, sum = 0;
            List<int[]> list = new ArrayList<>();
            while(l < r){
                sum = (l + r) * (r - l + 1) / 2;
                if(sum > target){
                    l++;
                }else if(sum < target){
                    r++;
                }else {
                    int[] ret = new int[r - l + 1];
                    for(int i = l; i <= r; ++i){
                        ret[i-l] = i;
                    }
                    list.add(ret);
                    l++;
                }
            }
            return list.toArray(new int[list.size()][]);
        }
    }
}